<template>
    <div>
<van-nav-bar
  title="搜索"
  left-text="返回"
  left-arrow
  @click-left="()=>{
    $router.back('/')
  }"
/>
<van-skeleton :row="7" :loading="!ispd"/>
<div v-if="ispd">
<van-search
  v-model="savl"
  shape="round"
  placeholder="请输入搜索关键词"
/>
<van-empty image="search" description="暂无搜索记录" v-if="savl.length==0||searchdata.length==0"/>
<div v-else>
<van-cell-group v-for="key in searchdata">
    <router-link :to="'/detail/'+key.goods_id">
  <van-cell :title="key.goods_name" />
  </router-link>
</van-cell-group>

</div>
  </div>
    </div>
</template>

<script setup>
import { ref,watch } from "vue";
import { qsearchApi } from "@/api/api";
import _ from "lodash";
let savl=ref('')
let searchdata=ref([])
watch(savl,_.debounce((savl)=>{
    qsearchApi(savl).then(res=>{
        console.log('search',res);
        searchdata.value=res.data.message
    })
},1500))
let ispd=ref(false)
    setTimeout(()=>{
        ispd.value=true
    },1500)
</script>

<style lang="scss" scoped>

</style>